<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>

        function add() {
            let trs = document.getElementsByTagName("tr");
            let sex = $("input:radio:checked").val();
            $("tr:last").after("<tr>\n" +
                "<th>" + (trs.length++) + "</th>\n" +
                "<th>" + $("input[name='username']").val() + "</th>\n" +
                "<th>" + $("input[name='pwd']").val() + "</th>\n" +
                "<th>"+(sex==='man'?'男':'女')+"</th>\n" + "</tr>")
        }

    </script>
</head>
<body>
点击按钮：将用户名、密码、性别添加到表单中。
<form>
    用户名：<input type="text" name="username"/>
    <br/>
    密码：<input type="password" name="pwd"/>
    <br/>
    性别：<input type="radio" name="sex" value="man" checked="checked"/>男
    <input type="radio" name="sex" value="woman"/>女
    <br/>
    <input type="button" value="添加到表格" onclick="add()"/>
</form>
<table cellspacing="0" border="1" width="100%">
    <tr>
        <th>序号</th>
        <th>用户名</th>
        <th>密码</th>
        <th>性别</th>
    </tr>
    <tr>
        <th>1</th>
        <th>zhangsan</th>
        <th>123123123</th>
        <th>男</th>
    </tr>
</table>
</body>
</html>